/*
1 页面加载的时候
  1冲缓存中获取购物车的数据 渲染到页面中
  这些数据  checkde=true

*/
 import { openSetting, chooseAddress, getSetting,showModal,showToast } from '../../utils/asyncWX.js';
 import regeneratorRuntime from '../../lib/runtime/runtime.js'
 Page({
     data: {
     address:{},
     cart:[],
     totalPrice: 0,
     totalNum:0
     },
     onShow(){
      //获取缓存中的收货地址
      const address =wx.getStorageSync("address");
      //获取缓存中的购物车数组
      let cart =wx.getStorageSync("cart")||[];
      //过滤后的购物车数组
      cart=cart.filter(v=>v.checked);
      this.setData({address});
        
      //总价格  总数量
      let totalPrice=0;
      let totalNum=0;
      cart.forEach(v => {
          totalPrice+=v.num*v.goods_price;
          totalNum+=v.num;
      })
      this.setData({
        cart,
        totalPrice,
        totalNum,
        address
      });
    },
    handlePlay(){
      wx.showToast({
        title: '暂时不支持支付功能！',
        icon: 'none'
      })
    }
 })